package com.learn.properties;

import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

@Component
@PropertySource(value = "classpath:application.properties")
@Getter
@Setter
public class AppProperties {
    @Value("${app.string}")
    private String string;
    
    @Value("${app.bool}")
    private Boolean bool;
    
    @Value("${app.date-time}")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date dateTime;
    
    /*@Value("${app.map}")
    private Map<String, String> map;*/
    
    @Value("${app.list}")
    private List<String> list;
    
    private Author author = new Author();
    
    @Getter
    @Setter
    public static class Author {
        @Value("${app.author.name}")
        private String name;
        
        @Value("${app.author.age}")
        private Integer age;
        
        @Value("${app.author.email}")
        private String email;
    }
}